package com.example.e_comm.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Data
@TableName("users")
public class User {

    public void setPassword(String password) {
        this.password = password;
    }
//    13-15 行代码修改UserController添加

    @TableId(type = IdType.AUTO)
    private Long id;

    private String username; // 用户名

    private String password; // 密码

    private String email; // 邮箱

    private Integer status; // 账户状态 0:禁用 1:正常

    @TableLogic(value = "0", delval = "1")
    private Integer deleted; // 0：没有删除 1:逻辑删除

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime = LocalDateTime.now();

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime = LocalDateTime.now();

    // 关联关系
    @TableField(exist = false)
    private List<Role> roles; // 用户角色列表

    @TableField(exist = false)
    private List<Permission> permissions; // 用户权限列表
}
